#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\SIG.h>



static void *storeFromStruct;

static int recordNum;
void registerSIG(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadSIGRecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerSIG(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(SIG_FILENAME, SIZE_SIG_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestoreSIGRecFromStruct(void *vdStruct)
{
	registerSIG(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetSIGRec(), vdStruct, SIZE_SIG_REC);

}

void vdCopySIGRecFromStruct(void *vdStruct)
{
	registerSIG(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetSIGRec(), SIZE_SIG_REC);

}

int	inSaveSIGRecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerSIG(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(SIG_FILENAME, SIZE_SIG_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdateSIGRecFromStruct (void *vdStruct)
{
	int inRet;

	registerSIG(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(SIG_FILENAME, SIZE_SIG_REC, recordNum, (char *) vdStruct);

	return inRet;
}

long lnGetCash1FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetCash1();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->lnCash1;
}

void vdSetCash1FromStruct(long lnCash1, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCash1(lnCash1);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->lnCash1 = lnCash1;
}

long lnGetCash2FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetCash2();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->lnCash2;
}

void vdSetCash2FromStruct(long lnCash2, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCash2(lnCash2);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->lnCash2 = lnCash2;
}

long lnGetCash3FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetCash3();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->lnCash3;
}

void vdSetCash3FromStruct(long lnCash3, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCash3(lnCash3);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->lnCash3 = lnCash3;
}

long lnGetCash4FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return lnGetCash4();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->lnCash4;
}

void vdSetCash4FromStruct(long lnCash4, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCash4(lnCash4);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->lnCash4 = lnCash4;
}

short inGetRegIntersetFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetRegInterset();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->inRegInterset;
}

void vdSetRegIntersetFromStruct(short inRegInterset, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRegInterset(inRegInterset);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->inRegInterset = inRegInterset;
}

short inGetPromoIntersetFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetPromoInterset();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->inPromoInterset;
}

void vdSetPromoIntersetFromStruct(short inPromoInterset, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPromoInterset(inPromoInterset);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->inPromoInterset = inPromoInterset;
}

VS_BOOL fGetEppSaleFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetEppSale();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fEppSale;
}

void vdSetEppSaleFromStruct(VS_BOOL fEppSale, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetEppSale(fEppSale);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fEppSale = fEppSale;
}

VS_BOOL fGetICashFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetICash();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fICash;
}

void vdSetICashFromStruct(VS_BOOL fICash, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetICash(fICash);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fICash = fICash;
}

VS_BOOL fGetSaleICashFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSaleICash();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSaleICash;
}

void vdSetSaleICashFromStruct(VS_BOOL fSaleICash, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSaleICash(fSaleICash);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSaleICash = fSaleICash;
}

VS_BOOL fGetRegFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetReg();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fReg;
}

void vdSetRegFromStruct(VS_BOOL fReg, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetReg(fReg);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fReg = fReg;
}

VS_BOOL fGetPromoFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetPromo();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fPromo;
}

void vdSetPromoFromStruct(VS_BOOL fPromo, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPromo(fPromo);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fPromo = fPromo;
}

VS_BOOL fGetPrintEPPFooterFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetPrintEPPFooter();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fPrintEPPFooter;
}

void vdSetPrintEPPFooterFromStruct(VS_BOOL fPrintEPPFooter, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPrintEPPFooter(fPrintEPPFooter);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fPrintEPPFooter = fPrintEPPFooter;
}

VS_BOOL fGetSIGPADBIT7FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT7();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT7;
}

void vdSetSIGPADBIT7FromStruct(VS_BOOL fSIGPADBIT7, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT7(fSIGPADBIT7);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT7 = fSIGPADBIT7;
}

VS_BOOL fGetSIGPADBIT8FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT8();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT8;
}

void vdSetSIGPADBIT8FromStruct(VS_BOOL fSIGPADBIT8, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT8(fSIGPADBIT8);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT8 = fSIGPADBIT8;
}

VS_BOOL fGetSIGPADBIT9FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT9();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT9;
}

void vdSetSIGPADBIT9FromStruct(VS_BOOL fSIGPADBIT9, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT9(fSIGPADBIT9);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT9 = fSIGPADBIT9;
}

VS_BOOL fGetSIGPADBIT10FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT10();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT10;
}

void vdSetSIGPADBIT10FromStruct(VS_BOOL fSIGPADBIT10, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT10(fSIGPADBIT10);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT10 = fSIGPADBIT10;
}

VS_BOOL fGetSIGPADBIT11FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT11();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT11;
}

void vdSetSIGPADBIT11FromStruct(VS_BOOL fSIGPADBIT11, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT11(fSIGPADBIT11);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT11 = fSIGPADBIT11;
}

VS_BOOL fGetSIGPADBIT12FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT12();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT12;
}

void vdSetSIGPADBIT12FromStruct(VS_BOOL fSIGPADBIT12, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT12(fSIGPADBIT12);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT12 = fSIGPADBIT12;
}

VS_BOOL fGetSIGPADBIT13FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT13();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT13;
}

void vdSetSIGPADBIT13FromStruct(VS_BOOL fSIGPADBIT13, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT13(fSIGPADBIT13);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT13 = fSIGPADBIT13;
}

VS_BOOL fGetSIGPADBIT14FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT14();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT14;
}

void vdSetSIGPADBIT14FromStruct(VS_BOOL fSIGPADBIT14, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT14(fSIGPADBIT14);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT14 = fSIGPADBIT14;
}

VS_BOOL fGetSIGPADBIT15FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT15();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT15;
}

void vdSetSIGPADBIT15FromStruct(VS_BOOL fSIGPADBIT15, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT15(fSIGPADBIT15);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT15 = fSIGPADBIT15;
}

VS_BOOL fGetSIGPADBIT16FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetSIGPADBIT16();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((SIG_REC*)vdStruct)->fSIGPADBIT16;
}

void vdSetSIGPADBIT16FromStruct(VS_BOOL fSIGPADBIT16, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetSIGPADBIT16(fSIGPADBIT16);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((SIG_REC*)vdStruct)->fSIGPADBIT16 = fSIGPADBIT16;
}

